/********************************************************************************
* File Name:	mainwindow.cpp
* Description:	第3章 实例2：ToolButton的实例
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
*
********************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolButton>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QToolButton *buttonNew = new QToolButton;
    buttonNew->setText("New");
    QToolButton *buttonOpen= new QToolButton;
    buttonOpen->setText("Open");
    QToolButton *buttonSave = new QToolButton;
    buttonSave->setText("Save");

    ui->mainToolBar->addWidget(buttonNew);
    ui->mainToolBar->addWidget(buttonOpen);
    ui->mainToolBar->addWidget(buttonSave);

    connect(buttonNew,SIGNAL(clicked()),this,SLOT(slotNew()));
    connect(buttonOpen,SIGNAL(clicked()),this,SLOT(slotOpen()));
    connect(buttonSave,SIGNAL(clicked()),this,SLOT(slotSave()));
}
void MainWindow::slotNew()
{
    ui->textEdit->setText("New");
}

void MainWindow::slotOpen()
{
    ui->textEdit->setText("Open");
}

void MainWindow::slotSave()
{
    ui->textEdit->setText("Save");
}

MainWindow::~MainWindow()
{
    delete ui;
}
